/**@author mayh,createDate:2006-4-6
 */
package com.manager;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

import lingtong.test.TestRead;

import com.zsoft.webmail.http.HttpUtils;

public class Bath_delmember {
public String del_number(String username) throws Exception {
		
		String url="http://"+new TestRead ().getPara("db.property","ymaildb_urlip")+"/webmailln/ext_jzst_delname.jsp?username="+username+"&hostname=10060.com";
		System.out.println("URL="+url);
		java.net.HttpURLConnection huc = HttpUtils.getConnection(url, null);
		HttpUtils.sendRequest(huc, null);
		String src = HttpUtils.getResponse(huc);
		return src;
	}
	public void bath_del(String path){
		String kaitong_start=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
		long start_time=System.currentTimeMillis();
		try {
			FileReader input = new FileReader(path);
			BufferedReader br = new BufferedReader(input);
			FileWriter output = new FileWriter(path.substring(0,(path.length()-4))+"_achieve.txt");
			BufferedWriter bw = new BufferedWriter(output);
			FileWriter output_error = new FileWriter(path.substring(0,(path.length()-4))+"_lost.txt");
			BufferedWriter bw_error = new BufferedWriter(output_error);
			FileWriter output_usetime = new FileWriter(path.substring(0,(path.length()-4))+"_usetime.txt");
			BufferedWriter bw_usetime = new BufferedWriter(output_usetime);
			String s = br.readLine();
			while (s != null) {
				try {
					String src=new Bath_delmember().del_number(s);
					bw.write(s+"    "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
					bw.newLine();
				} catch (Exception e) {
					bw_error.write(s+"    "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
					bw_error.newLine();
					e.printStackTrace();
				}
				s = br.readLine();
			}
			String kaitong_end=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
			String use_time=System.currentTimeMillis()-start_time+"";
			bw_usetime.write("start_time="+kaitong_start);
			bw_usetime.newLine();
			bw_usetime.write("end_time="+kaitong_end);
			bw_usetime.newLine();
			bw_usetime.write("use_time="+use_time);
			bw_usetime.newLine();
			br.close();
			bw_usetime.close();
			bw_error.close();
			bw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
}
